import request from '@/utils/request'

// 根据区码获取地域
export function getAreaInfo(areaCode) {
  return request({
    url: '/base/areaInfo.do?reverse=true&action=getAreaDetailInfo',
    method: 'post',
    params: { areaCode }
  })
}

// 获取区划 parentAreaCode: EARTH 全球，CHN 中国。 parentAreaCode: 区码
export function getAreaList(params) {
  return request({
    url: '/base/areaInfo.do?action=listTreeByParentAreaCode&excludeSupervise=true',
    method: 'post',
    params
  })
}

// 上传文件
export function uploadFile(params) {
  return request({
    url: '/file/uploadFile.do?action=upload',
    method: 'post',
    params
  })
}

// 新增base64图片
export function uploadByStr(params) {
  return request({
    url: '/upload/uploadFile.do?action=uploadByStr',
    method: 'post',
    params
  })
}

// 预览图片
export function getFile(fileId) {
  return '/manage/file/uploadFile.do?action=previewAsImage&fileId=' + fileId
}

// 预览图片
export function returnByFileId(fileId) {
  return request({
    url: '/file/uploadFile.do?action=previewAsImage&fileId=' + fileId
  })
}

// 获取部门
export function getDepartment() {
  return request({
    url: '/baseData/department.do?action=findChildDepartmentWithGenericity',
    method: 'post',
    params: {
      limit: 99999
    }
  })
}

// 获取字典
export function getDictionaryData(params) {
  return request({
    url: '/base/dictionaryData.do?action=list',
    method: 'GET',
    params
  })
}
